package top.dzygod.config;

import cn.hutool.log.Log;
import io.minio.MinioClient;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @author dzyGod
 */
@Component
@Slf4j
public class MinIOConfig {

    @Resource
    private MinIOParamConfig paramConfig ;

    /**
     * 初始化 MinIO 客户端
     * @return minio客户端
     */
    @Bean
    private MinioClient init(){
        try {
            return new MinioClient(paramConfig.getEndpoint(),
                                          paramConfig.getAccessKey(),
                                          paramConfig.getSecretKey());
        } catch (Exception e) {
            e.printStackTrace();
            log.info("MinIoClient init fail ...");
        }
        return null;
    }

}
